<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta name="format-detection" content="telephone=yes">
<title></title>
<link href="wx_assets/css/store.css?v=2013-11-30" rel="stylesheet"type="text/css">
<script src="http://res.wx.qq.com/mmbizwap/en_US/htmledition/js/wxm-core1530d0.js"></script>

<style>
abbr,article,aside,audio,canvas,datalist,details,dialog,eventsource,figure,figcaption,footer,header,hgroup,mark,menu,meter,nav,output,progress,section,small,time,video,legend
	{
	display: block;
}
</style>
<script>
document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
	WeixinJSBridge.call('showOptionMenu');
	});
	
var hrefParamsArray = GetParamsFromHref(window.location.search);

function GetParamsFromHref(search){
	var args = search.substring(1); 
　　	var retval = new Array(); 
	args = args.split("&"); 
		for(var i = 0; i < args.length; i ++){ 
			str = args[i]; 
			var arg = str.split("="); 
			if(arg.length <= 1) {
				continue; 
			}
			if(arg[0] == 'params') {
				var params = decodeURIComponent(arg[1]);
				var obj = eval('(' + params + ')');
				retval["id"] = obj.id;
				if (obj.start == undefined) {
					retval["start"] = 0;
				} else {
					retval["start"] = obj.start;
				}
				if (obj.name == undefined) {
					retval["name"] = '&nbsp;';
				} else {
					retval["name"] = obj.name;
				}
			} else if(arg[0] == 'customerId') {
				retval["customerId"] = arg[1]; 
			}else if(arg[0] == 'userName'){
				retval["userName"] = arg[1]; 
			} 
		} 
		if (retval["start"] == undefined) {
			retval["start"] = 0;
		}
		return retval; 
}

var limit = 10;
var pageCount = Math.ceil({$total} / limit);

var page = Math.ceil(hrefParamsArray["start"] / limit) + 1;

if({$total} == 0){
	pageCount = 1;
	page = 1;
}
</script>

</head>
<body id="page">
	<div class="header">
		<span class='top'>{$name}</span>
	</div>
	<div id = "page_order">
		<volist name="results" id="result">
		<section class="store">
		<article id="store_article"> 
			<empty name="result.picUrl">
				<div style="margin-top:10px">
				<h1>{$result.name}</h1>
				<p>{$result.address}</p>
				</div>
			<else />
				<span><img src={$result.picUrl}></span>
				<div class="desc">
					<h1>{$result.name}</h1>
					<p>{$result.address}</p>
				</div>
			</empty>
			
		</article>
		<ul>
			<li>
				<script type="text/javascript">
				var tel = "tel:" + '{$result.phone}';
				document.write("<a href=" + tel + ">\
					<span class='phone'></span>\
					<span class='title'>{$result.phone}</span>\
					<span class='arrow'></span></a>");
				</script>
			</li>
			<notempty name="result.contact">
			<li>
				<div class="item">
				<span class="contact"></span>
				<span class="title">{$result.contact}</span>
				</div>
			</li>
			</notempty>
			<notempty name="result.url">
			<li><a href="{$result.url}">
				<span class="detail"></span>
				<span class="title">查看自提点详细介绍</span>
				<span class="arrow"></span></a>
			</li>
			</notempty>
			<if condition="$result.onlineReserve eq 1">					
			<li>
				<a href='javascript:void(0)' onclick="reserve({$result.id})">
				<sapn class="reserve"></sapn>
				<span class="title">在线预订</span>
				<span class='arrow'></span></a>
			</li>
			</if>
			<if condition="$result.onlineOrder eq 1 AND $categoryType eq 1">					
			<li>
				<a href='javascript:void(0)' onclick="order({$result.id})">
				<sapn class="order"></sapn>
				<span class="title">点菜</span>
				<span class='arrow'></span></a>
			</li>
			</if>
			<if condition="$result.onlineTakeout eq 1 AND $categoryType eq 1">					
			<li>
				<a href='javascript:void(0)' onclick="takeout({$result.id})">
				<sapn class="takeout"></sapn>
				<span class="title">外卖</span>
				<span class='arrow'></span></a>
			</li>
			</if>
			<notempty name="result.type">
			<li>
				<div class="item">
				<span class="type"></span>
				<span class="title">{$result.type}</span>
				</div>
			</li>
			</notempty>
		</ul>
		</section>
		</volist>
	</div>
	
	<div class="pagination" id="pagination">
		<div id="pagePrev">
		<script>if (page != 1) {
			var baseUrl =  '{$Think.config.SERVER_HOST}';
			var start = parseInt(hrefParamsArray["start"]) - limit;
			var name = '{$result.name}';
			var urlString = baseUrl + 'call.html?customerId='+ hrefParamsArray["customerId"]+'&userName='+hrefParamsArray["userName"]
				+ "&module=store&method=getStoreList&params={\"id\":" + hrefParamsArray["id"] + ",\"name\":\"" +  hrefParamsArray["name"]
				+ "\",\"start\":" + start + "}#mp.weixin.qq.com";
			document.write("<a href='" + urlString + "'>上一页</a>");
		} else {
			document.write("<a href='javascript:void(0)' style='background:none;border:1px solid #cbcbcb;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;color:A4A3A3;cursor: default;'>上一页</a>");
		}
		</script>
		</div>
		<div class="allpage">
			<div class="currentpage"><script>document.write(page + "/" + pageCount);</script></div>
		</div>
		<div id="pageNext">
		<script>if (page != pageCount) {
			var baseUrl =  '{$Think.config.SERVER_HOST}';
			var start = parseInt(hrefParamsArray["start"]) + limit;
			var urlString = baseUrl + 'call.html?customerId='+ hrefParamsArray["customerId"]+'&userName='+hrefParamsArray["userName"]
				+ "&module=store&method=getStoreList&params={\"id\":" + hrefParamsArray["id"] + ",\"name\":\"" + hrefParamsArray["name"]
				+ "\",\"start\":" + start + "}#mp.weixin.qq.com";
			document.write("<a href='" + urlString + "'>下一页</a>");
		} else {
			document.write("<a href='javascript:void(0)' style='background:none;border:1px solid #cbcbcb;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;color:A4A3A3;cursor: default;'>下一页</a>");
		}
		</script>
		</div>
	</div>
	
	<script>
	if(pageCount == 1 && page == pageCount){
		document.getElementById("pagination").style.display="none";
	}
	
	function reserve(id) {
		var baseUrl =  '{$Think.config.SERVER_HOST}';
		var urlString = baseUrl + 'call.html?customerId='+ hrefParamsArray["customerId"]+'&userName='+hrefParamsArray["userName"]
			+ "&module=store"; 
		
		urlString += "&method=reserveSelNum&params={\"id\":" + id + "}";
		
		location.href= urlString;
	}
	
	function order(sid) {
		var baseUrl =  '{$Think.config.SERVER_HOST}';
		var urlString = baseUrl + 'call.html?customerId='+ hrefParamsArray["customerId"]+'&userName='+hrefParamsArray["userName"]
			+ "&module=product"; 
		urlString += "&method=orderDishes&params={\"sid\":" + sid + "}#wechat_webview_type=1";
		location.href= urlString;
	}
	function takeout(sid) {
		var baseUrl =  '{$Think.config.SERVER_HOST}';
		var urlString = baseUrl + 'call.html?customerId='+ hrefParamsArray["customerId"]+'&userName='+hrefParamsArray["userName"]
			+ "&module=product"; 
		urlString += "&method=takeoutDishes&params={\"sid\":" + sid + "}#wechat_webview_type=1";
		location.href= urlString;
	}
</script>

<script>
document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
	WeixinJSBridge.call('showOptionMenu');
});
	
(function() {
	var onBridgeReady = function() {
		var desString = '{$results[0]['name']}'+"\n...";
		desString = decodeURIComponent(desString);
		var titleString = '{$name}'+"自提点信息";
		var search = '?' + resetHerf(window.location.search);
		var link = window.location.protocol + "//"
				+ window.location.host + window.location.pathname + search;
		link = link.replace("{", "%7B");
		link = link.replace("}", "%7D");
		var appId = '', title = htmlDecode(titleString), desc = htmlDecode(desString),
		imgUrl = encodeURI('{$results[0]['picUrl']}'), desc = desc || link;

		// 发送给好友; 
		WeixinJSBridge.on('menu:share:appmessage', function(argv) {
			WeixinJSBridge.invoke('sendAppMessage', {
				"appid" : appId,
				"img_url" : imgUrl,
				"img_width" : "640",
				"img_height" : "640",
				"link" : link,
				"desc" : desc,
				"title" : title
			}, function(res) {
			});
		});
		// 分享到朋友圈;
		WeixinJSBridge.on('menu:share:timeline', function(argv) {
			WeixinJSBridge.invoke('shareTimeline', {
				"img_url" : imgUrl,
				"img_width" : "640",
				"img_height" : "640",
				"link" : link,
				"desc" : desc,
				"title" : title
			}, function(res) {
			});
		});

		// 分享到微博;
		var weiboContent = '';
		WeixinJSBridge.on('menu:share:weibo', function(argv) {
			WeixinJSBridge.invoke('shareWeibo', {
				"content" : title + link,
				"url" : link
			}, function(res) {
			});
		});
		// 隐藏右上角的选项菜单入口;
		//WeixinJSBridge.call('hideOptionMenu');
	};
	if (document.addEventListener) {
		document.addEventListener('WeixinJSBridgeReady', onBridgeReady,
				false);
	} else if (document.attachEvent) {
		document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
		document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
	}
})();
	
function resetHerf(search){
　　	var args = search.substring(1); 
　　	var retval = new Array(); 
	args = args.split("&"); 
	for(var i = 0; i < args.length; i ++){ 
		str = args[i]; 
		var arg = str.split("="); 
		if(arg.length <= 1) continue; 
		if(arg[0] == 'userName'){
			args[i] = "userName=";
			break;
		}
	} 
	return args.join("&");
}
</script>
</body>
</html>